<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<FiltronASP.Areas.Admin.ViewModels.Users.UsersIndexViewModel>" %>
<%@ Import Namespace="FiltronASP.Helpers.HtmlTags" %>
<%@ Import Namespace="FiltronASP.Helpers.Routes" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Zarządzanie użytkownikami
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="right-page-buttons2">
        <% Html.RenderPartial("TopIndexButtons"); %>
    </div>  
    <table class="right-pages usertable">
	    <tbody>
            <%if ((Model.PaginatedUsers == null) || (Model.PaginatedUsers.Count == 0))
            { //if null   %>
                <tr class="right-row">
                    <td class="right-cell-big">Brak użytkowników do wyświetlenia.</td>
                </tr>
            <% } else { //if menuItem type null   %>
                <% foreach (var user in Model.PaginatedUsers)
                   { %>
                    <% if ((Model.PaginatedUsers.IndexOf(user) % 2) == 0)
                       { %>
                        <tr class="right-row">
                            <td class="right-cell-username">
                            <%= Html.Image("admin-right-user.png") %>
                                <% if (user.user_first_name != null) { %>                                                     
			                                <%= user.user_first_name %>
                                    <% } //if not null     %> 
                           <% if (user.user_last_name != null){  %>  
                                        <%= user.user_last_name %>
                               
                                <% }    //if not null     %>                                                                   
					        </td>
					        <td class="right-cell-usermail">
					            <% if (user.user_mail_address != null){ %>
					                <%= user.user_mail_address%>     
					            <% } //if not last %>
					        </td>
					        <td class="right-cell-mid">
					        <% if (Model.PaginatedUsers.Count > 1 && user.user_id != 1) { %> 
					            <% if (Model.CurrentLanguage != null) { %>
                                    <%= Html.ActionLinkWithImage("admin-right-remove.png",
                                                    " Usuń", "Delete", new
                                                    {
                                                        userToDeleteId = (user.user_id),
                                                        currentLanguageId = (Model.CurrentLanguage.language_id),
                                                        page = (Model.PaginatedUsers.PageIndex)
                                                    })%>   
                                 <% } else { %>                 
                                    <%= Html.ActionLinkWithImage("admin-right-remove.png",
                                                    " Usuń", "Delete", new
                                                    {
                                                        userToDeleteId = (user.user_id),
                                                        page = (Model.PaginatedUsers.PageIndex)
                                                    })%>   
                                 <% } //else %>
                            <% } %>                                                  
					        </td>
					        <td class="right-cell-mid">
					            <% if (Model.CurrentLanguage != null) { %>
                                    <%= Html.ActionLinkWithImage("admin-right-edit.png",
                                                    " Edytuj", "Edit", new
                                                    {
                                                        login = (user.user_login),
                                                        userToEditId = (user.user_id),
                                                        currentLanguageId = (Model.CurrentLanguage.language_id),
                                                        page = (Model.PaginatedUsers.PageIndex)
                                                  })%>   
                                 <% } else { %>                 
                                    <%= Html.ActionLinkWithImage("admin-right-edit.png",
                                                    " Edytuj", "Edit", new
                                                    {
                                                        login = (user.user_login),
                                                        userToEditId = (user.user_id),                                                        
                                                        page = (Model.PaginatedUsers.PageIndex)
                                                  })%>   
                                 <% } //else %>
					        </td>
					        <td class="right-cell-wide">
					            <% if (Model.CurrentLanguage != null) { %>
                                        <%= Html.ActionLinkWithImage("admin-right-permissions.png",
                                                    " Uprawnienia", "EditUserPermissions", new
                                                    {                                                        
                                                        userToEditId = (user.user_id),
                                                        currentLanguageId = (Model.CurrentLanguage.language_id),
                                                        page = (Model.PaginatedUsers.PageIndex)
                                                    })%>   
                                 <% } else { %>                 
                                        <%= Html.ActionLinkWithImage("admin-right-permissions.png",
                                                    " Uprawnienia", "EditUserPermissions", new
                                                    {                                                        
                                                        userToEditId = (user.user_id),
                                                        page = (Model.PaginatedUsers.PageIndex)
                                                    })%>   
                                 <% } //else %>
					        </td>
                        </tr>					       
                    <% } else { //if odd row %>                       
                        <tr class="right-row altrow">
                            <td class="right-cell-username">
                            <%= Html.Image("admin-right-user.png") %>
                                <% if (user.user_first_name != null) { %>                                                     
			                                <%= user.user_first_name %>
                                    <% } //if not null     %> 
                           <% if (user.user_last_name != null){  %>  
                                        <%= user.user_last_name %>
                               
                                <% }    //if not null     %>                                                                   
					        </td>
					        <td class="right-cell-usermail">
					            <% if (user.user_mail_address != null){ %>
					                <%= user.user_mail_address%>     
					            <% } //if not last %>
					        </td>
					        <td class="right-cell-mid">
					        <% if (Model.PaginatedUsers.Count > 1 && user.user_id != 1) { %> 
					            <% if (Model.CurrentLanguage != null) { %>
                                    <%= Html.ActionLinkWithImage("admin-right-remove.png",
                                                    " Usuń", "Delete", new
                                                    {
                                                        userToDeleteId = (user.user_id),
                                                        currentLanguageId = (Model.CurrentLanguage.language_id),
                                                        page = (Model.PaginatedUsers.PageIndex)
                                                    })%>   
                                 <% } else { %>                 
                                    <%= Html.ActionLinkWithImage("admin-right-remove.png",
                                                    " Usuń", "Delete", new
                                                    {
                                                        userToDeleteId = (user.user_id),
                                                        page = (Model.PaginatedUsers.PageIndex)
                                                    })%>   
                                 <% } //else %>
                            <% } %>                                                  
					        </td>
					        <td class="right-cell-mid">
					            <% if (Model.CurrentLanguage != null) { %>
                                    <%= Html.ActionLinkWithImage("admin-right-edit.png",
                                                    " Edytuj", "Edit", new
                                                    {
                                                        login = (user.user_login),
                                                        userToEditId = (user.user_id),
                                                        currentLanguageId = (Model.CurrentLanguage.language_id),
                                                        page = (Model.PaginatedUsers.PageIndex)
                                                  })%>   
                                 <% } else { %>                 
                                    <%= Html.ActionLinkWithImage("admin-right-edit.png",
                                                    " Edytuj", "Edit", new
                                                    {
                                                        login = (user.user_login),
                                                        userToEditId = (user.user_id),                                                        
                                                        page = (Model.PaginatedUsers.PageIndex)
                                                  })%>   
                                 <% } //else %>
					        </td>
					        <td class="right-cell-wide">
					            <% if (Model.CurrentLanguage != null) { %>
                                        <%= Html.ActionLinkWithImage("admin-right-permissions.png",
                                                    " Uprawnienia", "EditUserPermissions", new
                                                    {                                                        
                                                        userToEditId = (user.user_id),
                                                        currentLanguageId = (Model.CurrentLanguage.language_id),
                                                        page = (Model.PaginatedUsers.PageIndex)
                                                    })%>   
                                 <% } else { %>                 
                                        <%= Html.ActionLinkWithImage("admin-right-permissions.png",
                                                    " Uprawnienia", "EditUserPermissions", new
                                                    {                                                        
                                                        userToEditId = (user.user_id),
                                                        page = (Model.PaginatedUsers.PageIndex)
                                                    })%>   
                                 <% } //else %>
					        </td>
                        </tr>			       
                    <% } //else odd row %>                       
                <% }    //foreach %>
            <% }    //else null %>
	    </tbody>
    </table>
    <div class="right-pagination">
        <% if ((Model.PaginatedUsers != null) && (Model.PaginatedUsers.Count > 0))
           { %>
            <% if (Model.PaginatedUsers.HasPreviousPage)
               { %>
                <a href="<%= Url.RouteUrl("UsersList", new {page = 1}) %>">
                    <img src="<%= Url.GenerateAdminImageLink("admin-right-first.png")%>" alt="pierwsza" />
                </a>
                <a href="<%= Url.RouteUrl("UsersList", new {user = (Model.PaginatedUsers.PageIndex - 1)}) %>">
                    <img src="<%= Url.GenerateAdminImageLink("admin-right-prev.png")%>" alt="poprzednia" />
                </a>
            <% } //if prev %>
            <% if ((Model.PaginatedUsers.HasPreviousPage) || (Model.PaginatedUsers.HasNextPage))
               { %>
                &nbsp;&nbsp;
                Strona <%= Model.PaginatedUsers.PageIndex%> z <%= Model.PaginatedUsers.PagesCount%>
                &nbsp;&nbsp;
            <% } //if %>
            <% if (Model.PaginatedUsers.HasNextPage)
               { %>
                <a href="<%= Url.RouteUrl("UsersList", new {user = (Model.PaginatedUsers.PageIndex + 1)}) %>">
                    <img src="<%= Url.GenerateAdminImageLink("admin-right-next.png")%>" alt="następna" />
                </a>
                <a href="<%= Url.RouteUrl("UsersList", new {user = Model.PaginatedUsers.PagesCount}) %>">
                    <img src="<%= Url.GenerateAdminImageLink("admin-right-last.png")%>" alt="ostatnia" />
                </a>
            <% } //if next %>    
        <% } //if not null and not empty %>    
    </div>    	                   
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeaderContent" runat="server">
        Zarządzanie użytkownikami
      
</asp:Content>
